package org.zpmis.domain.customer.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.zpmis.domain.customer.model.Intention;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class IntentionListVo {
    /**
     * 自增ID
     */
    private Long id;

    /**
     * 企业名称
     */
    private String name;

    /**
     * 意向描述
     */
    private String intentionDescript;

    /**
     * 联系人
     */
    private String contactPerson;

    /**
     * 联系手机号
     */
    private String contactMobile;

    /**
     * 是否删除 0否 1是
     */
    private Integer isDeleted;

    /**
     * 状态 0未启用 1启用
     */
    private Integer status;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String updateTime;

    /**
     * 客户来源 1官网 2其他
     */
    private Integer customerSource;

    /**
     * 企业code
     */
    private String companyCode;

    /**
     * 微信用户openId
     */
    private String openId;

    public IntentionListVo(Intention intention) {
        this.id = intention.getId();
        this.name = intention.getName();
        this.intentionDescript = intention.getIntentionDescript();
        this.contactPerson = intention.getContactPerson();
        this.contactMobile = intention.getContactMobile();
        this.isDeleted = intention.getIsDeleted();
        this.status = intention.getStatus();
        this.createTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(intention.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.updateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(intention.getUpdateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.customerSource = intention.getCustomerSource();
        this.companyCode = intention.getCompanyCode();
        this.openId = intention.getOpenId();
    }
}
